package org.homly.admin.tag.order;

import java.util.HashMap;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import org.homly.service.OrderService;
import org.homly.tool.StringTool;

/*
 * 查询一个订单
 */
@SuppressWarnings("serial")
public class OrderTag extends TagSupport {

	private String name;
	private String orderId;

	@SuppressWarnings("unchecked")
	@Override
	public int doStartTag() throws JspException {

		HashMap<String, String> order = null;

		Integer orderIdNum = null;
		if (orderId == null || !StringTool.isNumber(orderId)) {
			pageContext.setAttribute(name, new HashMap<String, String>());

			return SKIP_BODY;
		}
		orderIdNum = Integer.valueOf(orderId);

		HashMap para = new HashMap();
		para.put("id", orderIdNum);

		try {
			order = OrderService.getOrder(para);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		pageContext.setAttribute(name, order);

		return SKIP_BODY;
	}

	public void setName(String name) {
		this.name = name;
	}
	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}
}
